package qdb

import (
	"context"
	"time"

	"github.com/gogf/gf/frame/g"
	"go.mongodb.org/mongo-driver/bson"
)

// TxBlack TxBlack
type TxBlack struct {
	Domain     string    `bson:"Domain"`
	Source     string    `bson:"Source"`
	From       string    `bson:"from"`
	UpdateTime time.Time `bson:"update_time"` // 本条数据更新时间

}

// UpdateTxBlack UpdateTxBlack
func UpdateTxBlack(Domain string, source string) {
	ctx := context.Background()

	var domainInfo = TxBlack{
		Domain:     Domain,
		Source:     source,
		UpdateTime: time.Now(),
	}

	g.Log().Info("domainInfo", domainInfo)

	result, err := CollTxBlack.Upsert(ctx, bson.M{"Domain": domainInfo.Domain}, domainInfo)
	if err != nil {
		g.Log().Error(err)
	}

	g.Log().Info("result", result)

}
